package com.osdp.common.feign;

import com.osdp.common.feign.interceptor.FeignTokenInterceptor;
import com.osdp.common.util.TokenHolder;
import feign.Logger;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

/**
 * 注册feign访问附加 token 信息
 */
@Configurable
public class FeignAutoConfiguration {

    @Bean
    @ConditionalOnClass(TokenHolder.class)
    public FeignTokenInterceptor feignTokenInterceptor(){
        return new FeignTokenInterceptor();
    }

    @Bean
    @ConditionalOnMissingBean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }
}
